.amplify-radio {
  align-items: var(--amplify-components-radio-align-items);
  justify-content: var(--amplify-components-radio-justify-content);
  gap: inherit;
  flex-direction: row-reverse;
  // https://github.com/aws-amplify/amplify-ui/issues/3165
  // without a relatively positioned element in the ancestor tree,
  // focusing the hidden input might break some interfaces
  position: relative;
  &--disabled {
    cursor: var(--amplify-components-radio-disabled-cursor);
  }
}

.amplify-radio__button {
  flex-shrink: 0;
  align-items: var(--amplify-components-radio-button-align-items);
  justify-content: var(--amplify-components-radio-button-justify-content);
  padding: var(--amplify-components-radio-button-padding);
  box-sizing: var(--amplify-components-radio-button-box-sizing);
  border-width: var(--amplify-components-radio-button-border-width);
  border-style: var(--amplify-components-radio-button-border-style);
  border-radius: var(--amplify-components-radio-button-border-radius);
  border-color: var(--amplify-components-radio-button-border-color);
  color: var(--amplify-components-radio-button-color);
  background-color: var(--amplify-components-radio-button-background-color);
  transition-property: var(
    --amplify-components-radio-button-transition-property
  );
  transition-duration: var(
    --amplify-components-radio-button-transition-duration
  );
  width: var(--amplify-components-radio-button-width);
  height: var(--amplify-components-radio-button-height);

  // For case where box shadow doesn't work
  // https://stackoverflow.com/questions/65663864/does-replacing-a-form-inputs-outline-with-box-shadow-violate-any-wcag-guideline
  outline-color: var(--amplify-components-radio-button-outline-color);
  outline-style: var(--amplify-components-radio-button-outline-style);
  outline-width: var(--amplify-components-radio-button-outline-width);
  outline-offset: var(--amplify-components-radio-button-outline-offset);

  &::before {
    content: '';
    display: inline-block;
    width: 100%;
    height: 100%;
    border-radius: var(--amplify-components-radio-button-before-border-radius);
    background-color: currentColor;
    border-radius: 50%;
  }

  &--small {
    width: var(--amplify-components-radio-button-small-width);
    height: var(--amplify-components-radio-button-small-height);
  }

  &--large {
    width: var(--amplify-components-radio-button-large-width);
    height: var(--amplify-components-radio-button-large-height);
  }
}

.amplify-radio__input:checked + .amplify-radio__button {
  color: var(--amplify-components-radio-button-checked-color);
}

// checked and disabled state can coexist though data will not be submitted
.amplify-radio__input:checked:disabled + .amplify-radio__button {
  color: var(--amplify-components-radio-button-checked-disabled-color);
}

.amplify-radio__input:focus + .amplify-radio__button {
  border-color: var(--amplify-components-radio-button-focus-border-color);
  box-shadow: var(--amplify-components-radio-button-focus-box-shadow);
}

.amplify-radio__input[aria-invalid='true'] + .amplify-radio__button {
  border-color: var(--amplify-components-radio-button-error-border-color);
}

.amplify-radio__input[aria-invalid='true']:focus + .amplify-radio__button {
  box-shadow: var(--amplify-components-radio-button-error-focus-box-shadow);
}

.amplify-radio__input:disabled + .amplify-radio__button {
  border-color: var(--amplify-components-radio-button-disabled-border-color);
  background-color: var(
    --amplify-components-radio-button-disabled-background-color
  );
}

.amplify-radio__label {
  color: var(--amplify-components-radio-label-color);
  &--disabled {
    color: var(--amplify-components-radio-label-disabled-color);
  }
}
